package dialogs;

import java.awt.event.ActionEvent;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import controllers.AbstractController;
import controllers.DailySalesController;

public class DailySalesDialog extends AbstractGeneralPurposeDialog 
{
	DailySalesController controller;	
	
	public DailySalesDialog(JFrame parent, AbstractController c) 
	{
		super(parent, "Daily Sales", "Daily Sales", new String[] {"Store Name"}, c);
		controller = (DailySalesController) c;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getActionCommand().equals("OK"))
		{
			int retCode = controller.generateDailySales(text_fields.get(0).getText().trim());
			if(retCode == VALIDATIONERROR)
				JOptionPane.showMessageDialog(this, "Please fill in all of the fields", "Error",
						JOptionPane.ERROR_MESSAGE);
			else if(retCode == OPERATIONFAILED)
				JOptionPane.showMessageDialog(this, "Unable to generate daily sales report", "Error",
						JOptionPane.ERROR_MESSAGE);
			else 
				dispose();
		}

	}

}
